package vivek.project.pocketmoney.common
{

	public class FinancialFormulas
	{

		public static function calculateAbsReturns(investAmount:Number, currentValue:Number, sellAmount:Number, months:Number):Number
		{
			var absReturns:Number=0;
			if (currentValue != 0)
				absReturns=((currentValue - investAmount) / investAmount) * 100;
			else
				absReturns=((sellAmount - investAmount) / investAmount) * 100;
			return absReturns;
		}

		public static function calculateAnnualizedReturn(investAmount:Number, currentValue:Number, sellAmount:Number, days:Number):Number
		{
			var anReturns:Number=0;
			if (currentValue != 0)
				anReturns=Math.pow((currentValue / investAmount), 365 / days) - 1;
			else
				anReturns=Math.pow((sellAmount / investAmount), 365 / days) - 1;
			return anReturns * 100;
		}

		public static function calculateCAGR(investAmount:Number, currentValue:Number, sellAmount:Number, years:Number):Number
		{
			var exp:Number=1 / years;
			var cagr:Number=0;
			if (currentValue != 0)
				cagr=Math.pow((currentValue / investAmount), exp) - 1;
			else
				cagr=Math.pow((sellAmount / investAmount), exp) - 1;
			return cagr * 100;
		}

		public static function calculateCompoundInterest(investAmount:Number, rate:Number, compounded:int, years:Number):Number
		{
			var interest:Number=0;
			interest=investAmount * (Math.pow(1 + ((rate / 100) / compounded), (years * compounded)));
			return interest;
		}

		public static function getFinancialYear(date:Date):int
		{
			return 0;
		}

		public function FinancialFormulas()
		{
		}
	}
}